package com.oo.packaging_2.bankUser;

/**
 * BankUser--${description}
 *
 * @author: Jovi
 * @createTime: 2017-04-19 11:30
 **/
public class BankUser {

    private String userName;

    private String passWd;

    private String certNo;

    private String id;

    private double balance;


    public BankUser(String userName, String passWd, String certNo, String id, double balance) {
        this.userName = userName;
        this.passWd = passWd;
        this.certNo = certNo;
        this.id = id;
        this.balance = balance;
    }

    public BankUser() {
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWd() {
        return passWd;
    }

    public void setPassWd(String passWd) {
        this.passWd = passWd;
    }

    public String getCertNo() {
        return certNo;
    }

    public void setCertNo(String certNo) {
        this.certNo = certNo;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        if (balance < 0) {
            System.out.println("无效金额");
        } else {
            this.balance = balance;
        }

    }

    public void saving(String id,double money) {
        if (!this.getId().equals(id)) {
            System.out.println("账号错误");
            return;
        }
        if (money < 0) {
            System.out.println("存款金额无效");
        }
        this.balance+=money;
        System.out.println("存款成功！" + "\n姓名：" +this.getUserName()
                +"\n账号："+this.getId()+"\n可用金额："+this.getBalance()
        );
    }

    public void getting(String id, double money) {

        if (!this.getId().equals(id)) {
            System.out.println("账号错误");
            return;
        }
        if (money < 0) {
            System.out.println("取款金额无效");
            return;
        }
        if (balance < money) {
            System.out.println("账户余额不足");
            return;
        }
        this.balance-=money;
        System.out.println("取款成功!\n储户姓名" + this.getUserName() + "\n账号:"
                + this.getId()+"\n取款金额："+this.getBalance());
    }

}
